import math
import cv2

# variables
DISTANCE = 0.86  # M
HEIGHT = 0.26  # M

# focal length finder function
def focal_length(measured_distance, real_height, height_in_rf_image):
    focal_length_value = (height_in_rf_image * measured_distance) / real_height
    return focal_length_value

# distance estimation function
def distance_finder(focal_length, real_target_height, target_height_in_frame):
    distance = (real_target_height * focal_length)/target_height_in_frame
    return distance

def cal_displot(p1, p2):
    plotdis = math.sqrt(math.pow((p2[0]-p1[0]), 2) + math.pow((p2[1]-p1[1]), 2))
    return plotdis

# reading reference image from directory
ref_image_target_height = 238#206.72
focal_length_found = focal_length(
    DISTANCE, HEIGHT, ref_image_target_height)
print("focal_length_found=%f"%focal_length_found)
# print(math.sqrt(math.pow((480), 2) + math.pow((640), 2)))

